<?php /*a:6:{s:66:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\post\info.html";i:1660379677;s:63:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\layout.html";i:1659685605;s:68:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\meta.html";i:1659584544;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\script.html";i:1659584105;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\header.html";i:1660015203;s:70:"D:\phpstudy_pro\WWW\ThinkPHP\k2217ASK\app\home\view\common\footer.html";i:1659584054;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
<title>ask论坛</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="fly,layui,前端社区">
<meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
<link rel="stylesheet" href="/static/home/res/layui/css/layui.css">
<link rel="stylesheet" href="/static/home/res/css/global.css">


    <!-- 引入js -->
    <script src="/static/home/res/layui/layui.js"></script>
<script>
    layui.cache.page = '';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '/static/home/res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        version: "3.0.0"
        , base: '/static/home/res/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }).use('fly');
</script>
</head>

<body>
    <!-- 公共头部 -->
    <div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="<?php echo url('/'); ?>">
            <img src="/static/home/res/images/logo.png" alt="layui">
        </a>

        <?php if((app('request')->action() !== 'login' && app('request')->action() !== 'register')): ?>
        <ul class="layui-nav fly-nav-user">

            <!-- 未登入的状态 -->
            <?php if((!app('request')->cookie('LoginUser'))): ?>
            <li class="layui-nav-item">
                <a class="iconfont icon-touxiang layui-hide-xs" href="user/login.html"></a>
            </li>
            <li class="layui-nav-item">
                <a href="<?php echo url('/home/index/login'); ?>">登入</a>
            </li>
            <li class="layui-nav-item">
                <a href="<?php echo url('/home/index/register'); ?>">注册</a>
            </li>
            <?php else: ?>

            <!-- 登入后的状态 -->

            <li class="layui-nav-item">
                <a class="fly-nav-avatar" href="javascript:;">
                    <cite class="layui-hide-xs"><?php echo htmlentities($LoginUser['nickname']); ?></cite>
                    <?php if(($LoginUser['auth'] == 1)): ?>
                    <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：<?php echo htmlentities($LoginUser['nickname']); ?>"></i>
                    <?php endif; ?>
                    <i class="layui-badge fly-badge-vip layui-hide-xs">VIP <?php echo htmlentities($LoginUser['vip']); ?></i>
                    <img
                        src="<?php echo !empty($LoginUser['avatar']) ? '/' . $LoginUser['avatar']  :  '/static/home/res/images/avatar/default.png'; ?>">
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="<?php echo url('/home/user/profile'); ?>"><i class="layui-icon">&#xe620;</i>基本资料</a></dd>
                    <dd><a href="user/message.html"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
                    <dd><a href="/home/user"><i class="layui-icon"
                                style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
                    <hr style="margin: 5px 0;">
                    <dd><a href="<?php echo url('home/index/logout'); ?>" style="text-align: center;">退出</a></dd>
                </dl>
            </li>
            <?php endif; ?>
        </ul>
        <?php endif; ?>
    </div>
</div>

    <!-- 输出子内容 -->
    <!-- 引用编辑器 -->
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script src="/static/kindeditor/kindeditor-all.js"></script>
<script src="/static/kindeditor/lang/zh-CN.js"></script>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8 content detail">
            <div class="fly-panel detail-box">
                <h1><?php echo htmlentities($post['title']); ?></h1>
                <div class="fly-detail-info">
                    <!-- <span class="layui-badge">审核中</span> -->
                    <span class="layui-badge layui-bg-green fly-detail-column"><?php echo htmlentities($post['type']['name']); ?></span>

                    <!-- 帖子采纳 -->
                    <?php if($post['accept']): ?>
                    <span class="layui-badge" style="background-color: #5FB878;">已采纳</span>
                    <?php else: ?>
                    <span class="layui-badge" style="background-color: #999;">未采纳</span>
                    <?php endif; ?>

                    <!-- 帖子状态 -->
                    <?php if($post['state'] == 1): ?>
                    <span class="layui-badge layui-bg-orange">置顶</span>
                    <?php elseif($post['state'] == 2): ?>
                    <span class="layui-badge layui-bg-green">精华</span>
                    <?php elseif($post['state'] == 3): ?>
                    <span class="layui-badge layui-bg-red">热门</span>
                    <?php elseif($post['state'] == 0): ?>
                    <span class="layui-badge layui-bg-black">常规</span>
                    <?php endif; ?>

                    <div class="fly-admin-box" data-id="123">
                        <?php if($post['userid'] == $userid): ?>
                        <span class="layui-btn layui-btn-xs jie-admin" id="del" data-postid="<?php echo htmlentities($post['id']); ?>"
                            type="del">删除</span>
                        <?php endif; if($LoginUser && $post['userid'] != $userid): if($collect): ?>
                        <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="0"
                            data-postid="<?php echo htmlentities($post['id']); ?>" id="collect" style="background-color:#ccc;">取消收藏</span>
                        <?php else: ?>
                        <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick"
                            data-postid="<?php echo htmlentities($post['id']); ?>" id="collect" rank="1">收藏</span>
                        <?php endif; ?>
                        <?php endif; ?>
                        <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="0" style="background-color:#ccc;">取消置顶</span> -->

                        <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="1">加精</span> -->
                        <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="0" style="background-color:#ccc;">取消加精</span> -->
                    </div>
                    <span class="fly-list-nums">
                        <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> <?php echo htmlentities($post['comment_count']); ?></a>
                        <i class="iconfont" title="人气">&#xe60b;</i> <?php echo htmlentities($post['visit_count']); ?>
                    </span>
                </div>
                <div class="detail-about">
                    <a class="fly-avatar" href="<?php echo url('/home/user/index',['userid' => $post['userid']]); ?>">
                        <img src="<?php echo !empty($post['user']['avatar']) ? '/' . $post['user']['avatar']  :  '/static/home/res/images/avatar/default.png'; ?>"
                            alt="<?php echo htmlentities($post['user']['nickname']); ?>">
                    </a>
                    <div class="fly-detail-user">
                        <a href="<?php echo url('/home/user/index',['userid' => $post['userid']]); ?>" class="fly-link">
                            <cite><?php echo htmlentities($post['user']['nickname']); ?></cite>
                            <?php if($post['user']['auth'] == 1): ?>
                            <i class="iconfont icon-renzheng" title="认证信息：<?php echo htmlentities($post['user']['nickname']); ?>"></i>
                            <?php endif; ?>
                            <i class="layui-badge fly-badge-vip">VIP <?php echo htmlentities($post['user']['vip']); ?></i>
                        </a>
                        <span><?php echo htmlentities(date("Y-m-d",!is_numeric($post['createtime'])? strtotime($post['createtime']) : $post['createtime'])); ?></span>
                    </div>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
                        <span style="padding-right: 10px; color: #FF7200">悬赏：<?php echo htmlentities($post['point']); ?>积分</span>
                        <?php if($post['userid'] == $userid): ?>
                        <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a
                                href="<?php echo url('/home/post/edit',['postid' => $post['id']]); ?>">编辑此贴</a></span>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="detail-body photos">
                    <?php echo $post['content']; ?>
                </div>
            </div>

            <div class="fly-panel detail-box" id="flyReply">
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>回帖</legend>
                </fieldset>

                <ul class="jieda" id="jieda">
                    <?php if(count($CommentList) > 0): ?>
                    <?php echo CommentHtml($CommentList,$post,$LoginUser); else: ?>
                    <!-- 无数据时 -->
                    <!-- <li class="fly-none">消灭零回复</li> -->
                    <li class="fly-none">消灭零回复</li>
                    <?php endif; ?>
                </ul>

                <div class="layui-form layui-form-pane">
                    <?php if($LoginUser && !$post['accept']): ?>
                    <form action="<?php echo url('/home/comment/add'); ?>" method="post">
                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block">
                                <textarea name="content" style="width:100%;height: 260px;"
                                    placeholder="请输入内容"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="hidden" name="postid" value="<?php echo htmlentities($post['id']); ?>">
                            <!-- 评论父级id -->
                            <input type="hidden" name="pid" value="">
                            <button class="layui-btn" lay-submit>提交回复</button>
                        </div>
                    </form>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>

                <!-- 无数据时 -->
                <!--
          <div class="fly-none">没有相关数据</div>
          -->
            </dl>

            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img src="/static/home/res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
            </div>

        </div>
    </div>
</div>
<script>
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]');
    })

    layui.use(['layer'], function () {
        var $ = layui.jquery,
            layer = layui.layer;

        $('.accept').click(function () {
            var commentid = $(this).data('comid')

            layer.confirm('是否采纳该评论？', {
                title: '确认采纳'
            }, function (index) {

                $.ajax({
                    type: "post",
                    url: `<?php echo url('home/comment/accept'); ?>`,
                    data: {
                        commentid
                    },
                    dataType: "json",
                    success: function (res) {
                        if (res.code === 1) {
                            layer.msg(res.msg, function () {
                                location.reload()
                            })
                        } else {
                            layer.msg(res.msg)
                        }
                    }
                });



                layer.close(index)
            })
        })

        $('.jieda-zan').click(function () {

            var LikeCount = parseInt($(this).children('em').text())

            var commentid = $(this).data('id')

            // 把当前对象赋值给全局变量
            var that = $(this)

            $.ajax({
                type: "post",
                url: `<?php echo url('home/comment/like'); ?>`,
                data: {
                    commentid
                },
                dataType: "json",
                success: function (res) {
                    if (res.code === 1) {
                        if (that.hasClass('zanok')) {
                            that.removeClass('zanok')

                            that.children('em').text(LikeCount - 1)
                        } else {
                            that.addClass('zanok')

                            that.children('em').text(LikeCount + 1)
                        }
                    }
                }
            });
        })

        // 回复
        $(".reply").click(function () {
            var pid = $(this).data('pid')

            var nickname = $(this).data('nickname')

            $('input[name="pid"]').val(pid)

            $('#reply').html('回复@' + nickname)

            editor.focus()
        })

        // 删除帖子
        $('#del').click(function () {
            var postid = $(this).data('postid');

            // 确认提示框
            layer.confirm('确认删除该帖子？', {
                title: '删除'
            }, function (index) {
                $.ajax({
                    type: "post",
                    url: `<?php echo url('/home/post/del'); ?>`,
                    data: {
                        postid
                    },
                    dataType: "json",
                    success: function (res) {
                        if (res.code === 1) {
                            layer.msg(res.msg, function () {
                                location.href = res.url
                            })
                        } else {
                            layer.msg(res.msg)
                        }
                    }
                });

                // 关闭窗口
                layer.close(index)
            })
        });

        // 收藏/取消收藏

        $('#collect').click(function () {
            var postid = $(this).data('postid')

            $.ajax({
                type: "post",
                url: `<?php echo url('/home/collect/collect'); ?>`,
                data: {
                    postid
                },
                dataType: "json",
                success: function (res) {
                    if (res.code === 1) {
                        layer.msg(res.msg)
                        if (res.data) {
                            // 收藏操作
                            $('#collect').css({ backgroundColor: '#ccc' }).text('取消收藏')
                        } else {
                            // 取消操作
                            $('#collect').css({ backgroundColor: '#009688' }).text('收藏')
                        }
                    } else {
                        layer.msg(res.msg)
                    }
                }
            });
        })
    })

</script>

    <!-- 底部 -->
    <div class="fly-footer">
    <p>2017 &copy; <a href="http://www.layui.com/" target="_blank">Fly技术社区</a></p>
</div>

</body>

</html>